<?php

header("Content-type: text/html; charset=utf-8");

$title="【7.4正式】【T7崩溃】TOP";
$content="Step by Step：\n<br/><br/>\n\nActual Result：\n<br/><br/>\n\nExpected Result：\n<br/><br/>\n\nEnvironment Information(机型，OS等)：\n<br/><br/><br/>\n\nComments：\n";
$owner="kanguangyuan@baidu.com";
$buildVersion="7.4.14.0";
$buildInfo="7.4.14.0";
$engineVersion="7.9.0.55";



function http_post_data($url, $data_string) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(
		'Content-Type: application/json; charset=utf-8', 
		'Content-Length: ' . strlen($data_string))
	);
	ob_start();
	curl_exec($ch);
	$return_content = ob_get_contents();
	ob_end_clean();

	$return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
	return array($return_code, $return_content);
}



if ($_POST['Submit'] == "提交") {
	$url  = "http://icafe.baidu.com/api/v2/space/FLYFLOW/issue/new";
	$data = json_encode(array(
		"username"=>"zoubingsong",
		"password"=>"VVVsORhW7LDQYeo3RMfCdxx7fC5F2O8uW25", 
		"issues"=>[array(
			"title"=>$_POST['title'],
			"detail"=>$_POST['content'], 
			"type"=>"Bug",
			"fields"=>array(
				"负责人"=>$_POST['owner'], 
				"流程状态"=>"Active", 
				"Bug类型"=>"内核Bug", 
				"Severity"=>$_POST['severity'], 
				"Priority"=>$_POST['priority'], 
				"Build Version"=>$_POST['buildVersion'], 
				"Build Info"=>$_POST['buildInfo'], 
				"Tag"=>$_POST['tag'], 
				"所属计划"=>$_POST['plan'], 
				"产品线"=>$_POST['productLine'], 
				"Possibility"=>$_POST['possibility'], 
				"Engine Version"=>$_POST['engineVersion'], 
				"问题来源"=>"内部测试"
			),
			"notifyEmails"=>[$_POST['creator']."@baidu.com", $_POST['owner']],
			"creator"=>$_POST['creator']
		)]
	));

	list($return_code, $return_content) = http_post_data($url, $data);
	echo $return_content."<br/>";
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>创建icafe bug</title>
	<link href="css/style.css" rel="stylesheet" type="text/css" media="all"/>
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>
	<div class="login">
		<div class="login-main">
			<div class="login-top">
		 		<h1>创建icafe bug</h1>
				<form action="" method="post">
					Bug标题：<input type="text" placeholder="Bug标题" name="title" value="<?php echo $title;?>" style="width:580px;" />&nbsp;&nbsp;&nbsp;
					负责人：<input type="text" placeholder="负责人" name="owner" value="<?php echo $owner;?>" style="width:150px;" />&nbsp;&nbsp;&nbsp;
					创建人：<select name="creator">
								<option value="lvchengfeng" selected>吕成凤</option>
								<option value="zoubingsong">邹炳松</option>
								<option value="wangsiyuan03">王思远</option>
								<option value="chenfangzheng">陈方正</option>
								<option value="dongyuanli">董媛丽</option>
							</select><br />
					Bug内容：<textarea placeholder="Bug内容" name="content" style="width:99%;height:260px;"><?php echo $content;?></textarea><br /><br />
					Severity：<select name="severity">
								<option value="0-Highest">0-Highest</option>
								<option value="1" selected>1</option>
								<option value="2">2</option>
								<option value="3-Lowest">3-Lowest</option>
							</select>&nbsp;&nbsp;&nbsp;
					Priority：<select name="priority">
								<option value="P0-Highest">P0-Highest</option>
								<option value="P1-High" selected>P1-High</option>
								<option value="P2-Middle">P2-Middle</option>
								<option value="P3-Lowest">P3-Lowest</option>
							</select>&nbsp;&nbsp;&nbsp;
					Tag：<select name="tag">
								<option value="内核安装升级">内核安装升级</option>
								<option value="功能">功能</option>
								<option value="基础浏览">基础浏览</option>
								<option value="基础浏览/渲染异常">基础浏览/渲染异常</option>
								<option value="基础浏览/白屏">基础浏览/白屏</option>
								<option value="基础浏览/跳转异常">基础浏览/跳转异常</option>
								<option value="基础浏览/闪屏">基础浏览/闪屏</option>
								<option value="基础浏览/页面切换跳动">基础浏览/页面切换跳动</option>
								<option value="基础浏览/页面卡死">基础浏览/页面卡死</option>
								<option value="小窗，全屏，页内">小窗，全屏，页内</option>
								<option value="崩溃_ANR" selected>崩溃_ANR</option>
								<option value="性能">性能</option>
								<option value="机型兼容性">机型兼容性</option>
								<option value="模块">模块</option>
								<option value="模块/canvas_webgl">模块/canvas_webgl</option>
								<option value="模块/主题突出">模块/主题突出</option>
								<option value="模块/云端服务">模块/云端服务</option>
								<option value="模块/全屏">模块/全屏</option>
								<option value="模块/其他H5功能点">模块/其他H5功能点</option>
								<option value="模块/其它功能">模块/其它功能</option>
								<option value="模块/品牌外露">模块/品牌外露</option>
								<option value="模块/地址栏隐藏">模块/地址栏隐藏</option>
								<option value="模块/夜间模式">模块/夜间模式</option>
								<option value="模块/崩溃信息统计">模块/崩溃信息统计</option>
								<option value="模块/广告过滤">模块/广告过滤</option>
								<option value="模块/无图模式">模块/无图模式</option>
								<option value="模块/缩放">模块/缩放</option>
								<option value="模块/视频">模块/视频</option>
								<option value="模块/输入法">模块/输入法</option>
								<option value="模块/长按逻辑">模块/长按逻辑</option>
								<option value="模块/音频">模块/音频</option>
								<option value="模块/预加载">模块/预加载</option>
								<option value="页面兼容性">页面兼容性</option>
								<option value="页面兼容性问题">页面兼容性问题</option>
							</select><br /><br />
					所属计划：<select name="plan">
								<option value="Android平台7.5版本（百度浏览器）" selected>Android平台7.5版本（百度浏览器）</option>
								<option value="浏览内核项目/百度框">浏览内核项目/百度框</option>
								<option value="浏览内核项目/百度框/手百7.5版本">浏览内核项目/百度框/手百7.5版本</option>
								<option value="浏览内核项目/播放内核">浏览内核项目/播放内核</option>
								<option value="浏览内核项目/线上bug">浏览内核项目/线上bug</option>
								<option value="浏览内核项目/单View优化项目">浏览内核项目/单View优化项目</option>
								<option value="浏览内核项目/内核升级">浏览内核项目/内核升级</option>
								<option value="Android平台7.0正式版本">Android平台7.0正式版本</option>
								<option value="Android平台7.1版本">Android平台7.1版本</option>
								<option value="Android平台7.2版本">Android平台7.2版本</option>
								<option value="Android平台7.3版本">Android平台7.3版本</option>
								<option value="Android平台7.4版本">Android平台7.4版本</option>
								<option value="精简版OEM">精简版OEM</option>
							</select>&nbsp;&nbsp;&nbsp;
					Build Version：<input type="text" placeholder="Build Version" name="buildVersion" value="<?php echo $buildVersion;?>" />&nbsp;&nbsp;&nbsp;
					Build Info：<input type="text" placeholder="Build Info" name="buildInfo" value="<?php echo $buildInfo;?>" /><br /><br />
					产品线：<select name="productLine">
								<option value="百度手机浏览器" selected>百度手机浏览器</option>
								<option value="百度框">百度框</option>
								<option value="百度手机浏览器国际版">百度手机浏览器国际版</option>
							</select>&nbsp;&nbsp;&nbsp;
					Possibility：<select name="possibility">
								<option value="10%">10%</option>
								<option value="30%">30%</option>
								<option value="50%" selected>50%</option>
								<option value="80%">80%</option>
								<option value="100%">100%</option>
							</select>&nbsp;&nbsp;&nbsp;
					Engine Version：<input type="text" placeholder="Engine Version" name="engineVersion" value="<?php echo $engineVersion;?>" /><br /><br />
					<input type="submit" name="Submit" value="提交" />
				</form>
	 		</div>
		</div>
  </div>
</body>
</html>
